using UnityEngine;

public class SwitchButtonPositionLoader : MonoBehaviour
{
	[SerializeField]
	private ButtonPositionLoader _joystickCar;

	[SerializeField]
	private ButtonPositionLoader _buttonCar;

	[SerializeField]
	private ButtonPositionLoader _gyroscopeCar;

	[SerializeField]
	private ButtonPositionLoader _joystickTank;

	private void OnEnable()
	{
		switch (settings.typeControlerCar)
		{
		case TypeControlCar.camera:
			if (_joystickCar != null)
			{
				_joystickCar.enabled = false;
			}
			if (_buttonCar != null)
			{
				_buttonCar.enabled = false;
			}
			if (_gyroscopeCar != null)
			{
				_gyroscopeCar.enabled = true;
			}
			if (_joystickTank != null)
			{
				_joystickTank.enabled = false;
			}
			break;
		case TypeControlCar.button:
			if (_joystickCar != null)
			{
				_joystickCar.enabled = false;
			}
			if (_buttonCar != null)
			{
				_buttonCar.enabled = true;
			}
			if (_gyroscopeCar != null)
			{
				_gyroscopeCar.enabled = false;
			}
			if (_joystickTank != null)
			{
				_joystickTank.enabled = false;
			}
			break;
		case TypeControlCar.wheel:
			if (_joystickCar != null)
			{
				_joystickCar.enabled = true;
			}
			if (_buttonCar != null)
			{
				_buttonCar.enabled = false;
			}
			if (_gyroscopeCar != null)
			{
				_gyroscopeCar.enabled = false;
			}
			if (_joystickTank != null)
			{
				_joystickTank.enabled = false;
			}
			break;
		}
		if (PlayerBehavior.MyPlayer != null && PlayerBehavior.MyPlayer.currentCar != null && PlayerBehavior.MyPlayer.currentCar.Type == CarType.Tank)
		{
			if (_joystickCar != null)
			{
				_joystickCar.enabled = false;
			}
			if (_buttonCar != null)
			{
				_buttonCar.enabled = false;
			}
			if (_gyroscopeCar != null)
			{
				_gyroscopeCar.enabled = false;
			}
			if (_joystickTank != null)
			{
				_joystickTank.enabled = true;
			}
		}
	}
}
